"""
-*- coding: utf-8 -*-
@Time : 2021/11/26 18:58
@Author : XGT-Python
"""
# 导入相应的模块
import requests
import matplotlib.pyplot as plt  # 数据可视化模块
import json  # 数据转换

url = 'http://yunhq.sse.com.cn:32041//v1/sh1/line/000001?callback=jQuery112401330182933662667_1637926743625&begin=0&end=-1&select=time%2Cprice%2Cvolume&_=1637926743628'
response = requests.get(url).text
# 分析数据
json_result = response.lstrip('jQuery112401330182933662667_1637926743625(').rstrip(')')

# 转换
data = json.loads(json_result)
# 数据源头
data = data['line']

data_1 = [tony[0] for tony in data]
data_2 = [tony[1] for tony in data]
# for循环
index = range(len(data_1))
# 设置x轴要显示的标签
plt.xticks(index[::60], data_1[::60])
# 绘图
plt.plot(index, data_2,'red')
# 显示
plt.show()
# print(data_1)
# for循环
# print(index)
# 打印
# print(data['line'])
